package controller

import (
	"context"
	v1 "tFilm4/api/v1"
	"tFilm4/internal/model"
	"tFilm4/internal/service"
)

type cComment struct{}

var Comment = cComment{}

func (c *cComment) CreateComment(ctx context.Context, req *v1.CreateCommentReq) (res *v1.CreateCommentRes, err error) {
	err = service.Comment().CreateComment(ctx, model.CreateCommentInput{
		UserId:  req.UserId,
		MovieId: req.MovieId,
		Content: req.Content,
	})
	return
}
func (c *cComment) GetCommentByMovieId(ctx context.Context, req *v1.GetCommentByMovieIdReq) (res *v1.GetCommentByMovieIdRes, err error) {
	count, infos, err := service.Comment().GetCommentByMovieId(ctx, int(req.MovieId))
	res = &v1.GetCommentByMovieIdRes{
		CommentInfos: infos,
		Count:        count,
	}
	return
}
